home *** CD-ROM | disk | FTP | other *** search
- #include "global.h"
- #include "clipbrd.h"
- #include "comm.h"
- #include "debug.h"
- #include "desktop.h"
- #include "disk.h"
- #include "edit.h"
- #include "error.h"
- #include "event.h"
- #include "file.h"
- #include "find.h"
- #include "fontsel.h"
- #include "icon.h"
- #include "kurzel.h"
- #include "magx.h"
- #include "makro.h"
- #include "menu.h"
- #include "mintlib.h"
- #include "options.h"
- #include "printer.h"
- #include "projekt.h"
- #include "rsc.h"
- #include "scroll.h"
- #include "set.h"
- #include "text.h"
- #include "trash.h"
- #include "umbruch.h"
- #include "version.h"
- #include "windows.h"
-
-
- /****** VARIABLES ************************************************************/
-
- extern BOOLEAN abortProg; /* event.c */
-
- /****** FUNCTIONS ************************************************************/
-
- LOCAL BOOLEAN init_initerm (WORD argc, UBYTE *argv[]);
-
- /*****************************************************************************/
-
- VOID handleNix(VOID) /* was tun bei Signal? */
- {
- /* nix, einfach ignorieren! */
- }
-
- VOID handleTerm(VOID)
- {
- abortProg = TRUE;
- }
-
- WORD main(WORD argc, UBYTE *argv[], UBYTE *env[])
- {
- UBYTE *p, s[128];
- LONG v;
- WORD i, d;
- WORD old_tty_mode;
-
- gl_apid = appl_init ();
-
- #ifdef DEBUG
- DebugInit(DEBUG, DEBUGFILE, gl_apid);
- Debug("qed: started...\n");
- #endif /* DEBUG */
-
- #if 0
- {
- WORD i;
-
- Debug("qed: argc=%d\n", argc);
- for (i = 0; i < argc; i++)
- Debug("qed: argv[%d]=%s\n", i, argv[i]);
- }
- #endif
-
- if (global[0] == 0)
- exit(1);
- if (gl_apid < 0)
- exit(1);
- gem = global[0];
- mint = getcookie('MiNT', &v);
- aes41 = (gem >= 0x410);
- magx = check_magx();
-
- return_code = 0;
-
- if (aes41)
- {
- UBYTE titel[20];
-
- strcpy(titel, " qed ");
- strcat(titel, ProgrammVersion);
- (VOID) menu_register (gl_apid, titel);
- }
-
- Pdomain(1);
- Psignal(SIGINT, handleNix);
- Psignal(SIGSYS, handleNix);
- Psignal(SIGTERM, handleTerm);
- Psignal(SIGQUIT, handleTerm);
- Psignal(SIGHUP, handleTerm);
-
- old_tty_mode = 0; /* Consolen-Modus auf RAW schalten */
- raw_mode(&old_tty_mode);
-
- if (appl_xgetinfo(12, &i, &d, &d, &d) && (i&8)==8) /* gibts AP_TERM */
- shel_write(9, 1, 1, 0L, 0L); /* wir können es! */
-
- strcpy(app_path, "");
- strcpy(qed_path, "");
-
- if (argv[0][0] != EOS)
- strcpy(app_path, argv[0]);
- else
- shel_read(app_path, s);
-
- if (strlen(app_path) > 0)
- {
- p = strrchr (app_path, '\\');
- if (p == NULL) /* Kein Pfad */
- app_path[0] = EOS;
- else
- {
- p++;
- str_upper(p);
- if (strncmp(p, "QED", 3))
- app_path[0] = EOS;
- else
- *p = EOS;
- }
- if (app_path[0] != EOS)
- if (!make_normalpath(app_path, FALSE))
- app_path[0] = EOS;
- }
-
- if (init_initerm(argc, argv))
- {
- hndl_events();
-
- menu_bar (NULL, FALSE); /* Menüzeile freigeben */
- term_comm();
- term_project();
- }
- term_resource ();
- term_global (); /* Terminiere global */
- appl_exit (); /* Applikation beenden */
-
- raw_mode(&old_tty_mode); /* Consolen-Modus zurücksetzen */
-
- #ifdef DEBUG
- Debug("qed: finished.\n");
- DebugExit();
- #endif
- return (return_code);
- }
-
- /***************************************************************************/
- /* Initialisieren des Moduls */
- /***************************************************************************/
-
- LOCAL VOID find_qed(VOID)
- {
- UBYTE *p;
- BOOLEAN found = FALSE;
-
- if (!get_qed(qed_path)) /* Parameterdatei wurde übergeben */
- {
- p = getenv("HOME"); /* im Environment nachschauen */
- if (p != NULL)
- {
- strcpy(qed_path, p);
- if (make_normalpath(qed_path, FALSE))
- strcat(qed_path, "default.qed");
- found = file_exist(qed_path);
- }
-
- p = getenv("QED");
- if (!found && (p != NULL))
- {
- strcpy(qed_path, p);
- if (make_normalpath(qed_path, FALSE))
- strcat(qed_path, "default.qed");
- found = file_exist(qed_path);
- }
-
- if (!found && app_path[0] != EOS) /* im Programmpfad */
- {
- strcpy(qed_path, app_path);
- strcat(qed_path, "default.qed");
- found = file_exist(qed_path);
- }
-
- if (!found && file_exist("default.qed")) /* im aktueller Ordner */
- {
- get_path(qed_path, 0);
- strcat(qed_path, "default.qed");
- found = TRUE;
- }
-
- if (found)
- {
- if (!caseSens(qed_path, NULL))
- str_upper(qed_path);
- }
- else
- qed_path[0] = EOS;
- }
- }
-
-
- LOCAL BOOLEAN init_initerm (WORD argc, UBYTE *argv[])
- {
- BOOLEAN ok;
- WORD i;
- UBYTE str[256];
- CICONBLK *cicon;
-
- ok = TRUE;
- init_global();
-
- init_default_var();
-
- if (!init_resource())
- return FALSE;
- if (desk.w < 80 * sys_wchar || desk.h < 23 * sys_hchar)
- {
- note(1, SCREEN);
- return FALSE;
- }
- init_windows();
- init_icon();
- init_memory();
- init_text();
- init_edit();
- init_makro ();
- init_marken();
- init_desktop ();
- init_disk ();
- init_printer ();
- init_projekt ();
-
- if (argc > 1)
- {
- for (i = 1; i < argc; i++)
- {
- /*
- * Wenn ein Argument ein Leerzeichen enthält, klammern wir das in ',
- * damit es bei add_diskinfo korrekt erkannt wird.
- */
- if (strchr(argv[i], ' ') != NULL)
- {
- strcpy(str, "\'");
- strcat(str, argv[i]);
- strcat(str, "\'");
- }
- else
- strcpy(str, argv[i]);
- add_diskinfo(str, FALSE);
- }
- }
-
- find_qed(); /* qed-File in Parametern ? */
- option_load();
-
- if (!icon_anz(disk_type))
- {
- cicon = (CICONBLK *)get_obspec(icons, IDISK);
- idisk = add_icon_to_desk(IDISK, cicon->monoblk.ib_ptext, -1, -1);
- add_icon(disk_type, idisk);
- }
- if (!icon_anz(printer_type))
- {
- cicon = (CICONBLK *)get_obspec(icons, IPRINTER);
- iprinter = add_icon_to_desk(IPRINTER, cicon->monoblk.ib_ptext, -1, -1);
- add_icon(printer_type, iprinter);
- }
-
- init_comm();
- init_clipbrd ();
- init_trash ();
-
- ok &= init2_desktop();
-
- /* wird angeschaltet, sobald Default-Prj geladen! */
- menu_ienable(menu, MTAKEPRJ, FALSE);
-
- if (overwrite)
- {
- menu_icheck(menu, MOEINF, FALSE);
- menu_icheck(menu, MOOVERW, TRUE);
- }
- else
- {
- menu_icheck(menu, MOEINF, TRUE);
- menu_icheck(menu, MOOVERW, FALSE);
- }
-
- if (ok)
- {
- menu_bar (menu, TRUE);
- wind_update (BEG_UPDATE);
- do_icon(0, DO_OPEN);
- open_multidisk();
- wind_update (END_UPDATE);
- }
-
- return (ok);
- } /* init_initerm */
-